import Head from "next/head";
import Header from "../../components/header/index";
import Footer from "../../components/footer/index";
import HouseList from "../../components/house-list/index";
import Map from "../../components/map/index";
import "./index.scss";

const Houses = (props) => {
	const { points, blogStore } = props;
	return (
		<React.Fragment>
			<Head>
				<title>JustDoDo | 西安房市</title>
				<meta name="keywords" content="justdodo,博客,房市" />
			</Head>
			<div className="main">
				<Header blogStore={blogStore}></Header>
				<div className="main-content">
					<Map points={points} />
					<HouseList data={points} />
				</div>
				<Footer></Footer>
			</div>
		</React.Fragment>
	);
};

Houses.getInitialProps = async (ctx, store) => {
	let result = await store.houseStore.getList({pageCount: Infinity});
	if(result && result.list) {
		return {
			points: result.list
		};
	}
};

export default Houses;